const INFO_KEY = 'token_key'
const SEARCH_KEY = 'search_history'

// 获取个人信息
export const getInfo = () => {
  const result = localStorage.getItem(INFO_KEY)
  return result ? result : ''
  // return result ? JSON.parse(result) :{
  //   token: '',
  //   userId: ''
  // }
}

// 设置个人信息
export const setInfo = (info) => {
  // localStorage.setItem(INFO_KEY, JSON.stringify(info))
  localStorage.setItem(INFO_KEY, info)
}

// 移除个人信息
export const removeInfo = () => {
  localStorage.removeItem(INFO_KEY)
}

// 获取搜索历史
export const getSearchHistory = () => {
  const result = localStorage.getItem(SEARCH_KEY)
  return result ? JSON.parse(result) : []
}

// 存入搜索历史
export const setSearchHistory = (history) => {
  // localStorage.setItem(SEARCH_KEY, )
  localStorage.setItem(SEARCH_KEY, JSON.stringify(history))
}

